import request from "@/utils/request";
import type { GetRoleListResponse } from "./model/roleModel";

enum Api {
  getRoleListUrl = "/admin/acl/role",
  saveRoleUrl = "/admin/acl/role/save",
}

/**
 * 获取角色列表
 * @param page 当前页码
 * @param limit 每页条数
 * @param roleName 角色名称
 * @returns GetRoleListResponse
 */
export const getRoleListApi = (page: number, limit: number, roleName = "") => {
  return request.get<any, GetRoleListResponse>(
    Api.getRoleListUrl + `/${page}/${limit}`,
    {
      params: {
        roleName,
      },
    }
  );
};

/**
 * 添加角色
 * @param roleName 角色名称
 * @returns null
 */
export const saveRoleApi = (roleName: string) => {
  return request.post<any, null>(Api.saveRoleUrl, {
    roleName,
  });
};
